package com.pmc.insfracture.student.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pmc.domain.student.entity.Student;
import com.pmc.domain.student.repository.StudentRepository;
import com.pmc.domain.student.vo.StudentQueryVO;
import com.pmc.insfracture.student.mapper.StudentMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * StudentDao
 *
 * @author hudeng
 * @version 1.0
 * @description dao
 * @date 2024/7/4 10:54
 */
@Repository
public class StudentDao implements StudentRepository {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> queryList(StudentQueryVO queryVO) {
        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
        String name = queryVO.getName();
        if (StringUtils.isNotEmpty(name)) {
            queryWrapper.lambda().eq(Student::getName, name);
        }
        return studentMapper.selectList(queryWrapper);
    }
}
